package com.jege.spring.boot.mybatis.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.jege.spring.boot.mybatis.entity.User;

/**
 * @author JE哥
 * @email 1272434821@qq.com
 * @description:持久层接口，由spring自动生成其实现
 */
@Mapper
public interface UserMapper {
  @Delete("drop table t_user if exists")
  void dropTable();

  @Insert("create table t_user (id bigint generated by default as identity, age integer, name varchar(255), primary key (id))")
  void createTable();

  @Insert("insert into t_user(name,age) values(#{name},#{age})")
  void insert(User user);

  @Select("select id,name,age from t_user")
  List<User> findAll();

  @Select("select id,name,age from t_user where name like #{name}")
  List<User> findByNameLike(String name);

  @Delete("delete from t_user")
  void deleteAll();

}
